package com.zgis.module.bas.bean;

import java.math.BigDecimal;
import java.sql.Timestamp;

/**
 * 修改记录:
 * 24-09-29     zhengchaojun             首次创建
 */

/**
 * 类描述：存储过程参数管理类
 */
public class CxPro
{
    /**
     * 参数模式枚举
     */
    public enum ParameterMode {
        IN, OUT, REF_CURSOR
    }

    public ParameterMode parameterMode = ParameterMode.IN;

    public String mode = "IN";

    public String jdbcType = "VARCHAR";

    public Object value;

    public Class clazz = String.class;

    public void setClazz(String jdbcType)
    {
        if(jdbcType.equals("VARCHAR") || jdbcType.equals("CHAR"))
        {
            this.clazz = String.class;
        }
        else if(jdbcType.equals("INTEGER"))
        {
            this.clazz = Integer.class;
        }
        else if(jdbcType.equals("DOUBLE"))
        {
            this.clazz = Double.class;
        }
        else if(jdbcType.equals("FLOAT"))
        {
            this.clazz = Float.class;
        }
        else if(jdbcType.equals("DATE"))
        {
            this.clazz = java.sql.Date.class;
        }
        else if(jdbcType.equals("TIMESTAMP"))
        {
            this.clazz = Timestamp.class;
        }
        else if(jdbcType.equals("BLOB"))
        {
            this.clazz = byte[].class;
        }
        else if(jdbcType.equals("CLOB"))
        {
            this.clazz = String.class;
        }
        else if(jdbcType.equals("BOOLEAN"))
        {
            this.clazz = Boolean.class;
        }
        else if(jdbcType.equals("DECIMAL"))
        {
            this.clazz = BigDecimal.class;
        }
        else if(jdbcType.equals("NUMERIC"))
        {
            this.clazz = BigDecimal.class;
        }
        else if(jdbcType.equals("BIGINT"))
        {
            this.clazz = Long.class;
        }
        else if(jdbcType.equals("TINYINT"))
        {
            this.clazz = Byte.class;
        }
        else
        {
            this.clazz = String.class;
        }
    }

    public ParameterMode getParameterMode()
    {
        if (mode.equals("IN"))
        {
            parameterMode = ParameterMode.IN;
        }
        if (mode.equals("OUT"))
        {
            parameterMode = ParameterMode.OUT;
        }
        if (mode.equals("REF_CURSOR"))
        {
            parameterMode = ParameterMode.REF_CURSOR;
        }
        else
        {
            parameterMode = ParameterMode.IN;
        }
        return parameterMode;
    }
}